//
//  FourthViewController.m
//  UI08_导航控制器
//
//  Created by Scott on 15/4/28.
//  Copyright (c) 2015年 www.lanou3g.com 蓝欧3G. All rights reserved.
//

#import "FourthViewController.h"

@interface FourthViewController ()

@end

@implementation FourthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor grayColor];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(20, 100, 100, 40);
    [button setTitle:@"Back" forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:button];
    
    
}

- (void)buttonClicked:(UIButton *)button
{
    /* 出栈 */
    /* 1. 返回上一页 */
    [self.navigationController popViewControllerAnimated:YES];
    
    /* 2. 返回根视图控制器(首页) */
    [self.navigationController popToRootViewControllerAnimated:YES];
    
    /* 3. 返回到一个指定界面 */
    /* 获取栈中的的viewController */
    UIViewController *view  = [self.navigationController.viewControllers objectAtIndex:1];
    
    [self.navigationController popToViewController:view animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
